# -*- coding: utf-8 -*-
"""
Created on Mon Nov 23 17:59:52 2020
# https://selenium-python.readthedocs.io/getting-started.html
driver.page_source === page_source method is used retrieve the page source of the webpage the user is currently accessing. 
The main use of this method to find something in the page source like finding any data or keyword.
@author: andrew
"""
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome('./diver/chromedriver')
driver.get("http://www.baidu.com")
# time.sleep(5)
print(driver.title)
# print(driver.page_source)
# time.sleep(5)
# driver.close()

# assert "Python" in driver.title
# elem = driver.find_element_by_name("q")
elem = driver.find_element_by_id('kw')
elem.clear()
elem.send_keys("python")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
time.sleep(5)
driver.close()

